home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / math / gle-3.000 / gle-3 / gle / mouse.c < prev    next >
C/C++ Source or Header  |  1995-02-07  |  3KB  |  157 lines

  1. #include <dos.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. /* changes for DJGPP/GRX by Hartmut Schirmer and Axel Rohde */
  6. #ifdef DJ
  7. #  include <grx.h>
  8. #  include <mousex.h>
  9. #endif
  10.  
  11. #define false (0)
  12. #define true (!0)
  13. void mousecursor( int toggle);
  14. /*
  15. main()
  16. {
  17.     for (;;) {
  18.         mousecursor(true);
  19.         printf("Mouse col %d  %d \n",mousecol(),mouserow());
  20.         delay(1000);
  21.     }
  22. }
  23.  
  24. */
  25.  
  26. int mousebuttons()                    /* see if mouse buttons are pressed */
  27. {
  28. #ifdef DJ
  29.    MouseEvent event;
  30.  
  31.    MouseGetEvent( M_BUTTON_DOWN | M_POLL, &event);
  32.    return event.buttons & 3;
  33. #else
  34.    union REGS inregs;
  35.    union REGS outregs;
  36.    inregs.x.ax = 6;
  37.    int86(0x33,&inregs,&outregs);
  38.    return(outregs.x.ax & 3);
  39. #endif
  40. }
  41.  
  42.  
  43.  
  44. int mousecheck()                      /* see if mouse exists, & # of buttons */
  45. {
  46. #ifdef DJ
  47.    if (!MouseDetect()) return 0;
  48.    MouseInit();
  49.    return 2;
  50. #else   
  51.    union REGS inregs;
  52.    union REGS outregs;
  53.    inregs.x.ax = 0;
  54.    int86(0x33,&inregs,&outregs);
  55.    return(outregs.x.ax ? outregs.x.bx : 0);
  56. #endif
  57. }
  58.  
  59.  
  60.  
  61. int mouseclick()                      /* see if mouse buttons were clicked */
  62. {
  63. #ifdef DJ
  64.    MouseEvent event, event2;
  65.    
  66.    MouseGetEvent( M_BUTTON_DOWN|M_POLL, &event);
  67.    if (event.buttons) {
  68.          MouseGetEvent( M_BUTTON_UP | M_POLL, &event2);
  69.          MouseGetEvent( M_BUTTON_UP, &event);
  70.          return 3 & event2.buttons;
  71.    }
  72.    return 0;   
  73. #else
  74.    int click = 0;
  75.    union REGS inregs;
  76.    union REGS outregs;
  77.    inregs.x.ax = 5;
  78.    inregs.x.bx = 1;
  79.    int86(0x33,&inregs,&outregs);
  80.    click = outregs.x.bx << 1;
  81.    inregs.x.bx--;
  82.    int86(0x33,&inregs,&outregs);
  83.    return(click | outregs.x.bx);
  84. #endif
  85. }
  86.  
  87.  
  88.  
  89. int mousecol()                        /* get column where mouse cursor is */
  90. {
  91. #ifdef DJ
  92.    MouseEvent event;
  93.    
  94.    MouseGetEvent( M_MOTION | M_POLL, &event);
  95.    return event.x;
  96. #else
  97.    union REGS inregs;
  98.    union REGS outregs;
  99.    inregs.x.ax = 3;
  100.    int86(0x33,&inregs,&outregs);
  101.    return(outregs.x.cx);
  102. #endif
  103. }
  104.  
  105.  
  106.  
  107. void mousecursor(toggle)              /* turn mouse cursor on or off */
  108.    int toggle;
  109. {
  110. #ifdef DJ
  111.    if (toggle) MouseDisplayCursor();
  112.           else MouseEraseCursor();
  113. #else
  114.    union REGS inregs;
  115.    union REGS outregs;
  116.    if (toggle) inregs.x.ax = 1;
  117.    else inregs.x.ax = 2;
  118.    int86(0x33,&inregs,&outregs);
  119. #endif
  120. }
  121.  
  122.  
  123.  
  124. void mouseloc(column,row)             /* set location of mouse cursor */
  125.    int column, row;
  126. {
  127. #ifdef DJ
  128.    MouseWarp(column, row);
  129. #else
  130.    union REGS inregs;
  131.    union REGS outregs;
  132.    inregs.x.ax = 4;
  133.    inregs.x.cx = column;
  134.    inregs.x.dx = row;
  135.    int86(0x33,&inregs,&outregs);
  136. #endif
  137. }
  138.  
  139.  
  140.  
  141. int mouserow()                        /* get row where mouse cursor is */
  142. {
  143. #ifdef DJ
  144.    MouseEvent event;
  145.    
  146.    MouseGetEvent( M_MOTION | M_POLL, &event);
  147.    return event.y;
  148. #else
  149.    union REGS inregs;
  150.    union REGS outregs;
  151.    inregs.x.ax = 3;
  152.    int86(0x33,&inregs,&outregs);
  153.    return(outregs.x.dx);
  154. #endif
  155. }
  156.  
  157.